package com.huaqin.excel.util;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * This a Utils class for International
 * 
 * @author qiujianxiong
 * 
 */
public class InternationalUtils {

	// avoid initialize
	private InternationalUtils() {

	}

	// values_xx_xx.properties store the key and values.
	// this method can read values of str from properties
	public static String getStringFromProperties(String str) {

		/**
		 * this method can get special language string. for example:if you want
		 * to get American English,you should have a values_en_US.properties,
		 * Locale mLocale = new Locale("en", "US"); 
		 * ResourceBundle bundle =ResourceBundle.getBundle("values", myLocale); 
		 * String string = bundle.getString(str);
		 * 
		 * you also can use Locale.getDefault() to get the default local
		 * language. Locale myLocale = Locale.getDefault();
		 */

		// get values from values_zh_CN.properties.
		Locale myLocale = new Locale("zh", "CN");
		ResourceBundle bundle = ResourceBundle.getBundle("values", myLocale);
		String string = bundle.getString(str);
		return string;
	}
	
	/**
	 * @param a
	 * @param b
	 * @return
	 */
	public static boolean equals(CharSequence a, CharSequence b) {
        if (a == b) return true;
        int length;
        if (a != null && b != null && (length = a.length()) == b.length()) {
            if (a instanceof String && b instanceof String) {
                return a.equals(b);
            } else {
                for (int i = 0; i < length; i++) {
                    if (a.charAt(i) != b.charAt(i)) return false;
                }
                return true;
            }
        }
        return false;
    }
	
	/**
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(CharSequence str) {
        if (str == null || str.length() == 0)
            return true;
        else
            return false;
    }
	
	

}
